package com.distributer.report.domain.statistics.valueobj;

import java.io.Serializable;

import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSONObject;

/**
 * 订单值对象
 * @author xiaolin
 *
 */
public class OrderValueObj implements Serializable{

	private static final long serialVersionUID = 1210483962065137739L;

	private String orderNo;
	
	private String productCode;
	
	private String productName;
	
	private Integer orderStatus;
	
	private String orderPremium;
	
	private final String messageId;

	public OrderValueObj(String dataSource,String messageId) {
		if (StringUtils.isEmpty(dataSource)) {
			throw new NullPointerException("订单消息为空！");
		}
		JSONObject orderDataJson = JSONObject.parseObject(dataSource);
		this.productCode = orderDataJson.getString("productCode");
		this.productName = orderDataJson.getString("productName");
		this.orderStatus = orderDataJson.getInteger("orderStatus");
		this.orderPremium = orderDataJson.getString("orderPremium");
		this.orderNo = orderDataJson.getString("orderNo");
		this.messageId = messageId;
	}
	
	public String getOrderNo() {
		return orderNo;
	}

	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}

	public String getProductCode() {
		return productCode;
	}

	public void setProductCode(String productCode) {
		this.productCode = productCode;
	}

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public Integer getOrderStatus() {
		return orderStatus;
	}

	public void setOrderStatus(Integer orderStatus) {
		this.orderStatus = orderStatus;
	}

	public String getOrderPremium() {
		return orderPremium;
	}

	public void setOrderPremium(String orderPremium) {
		this.orderPremium = orderPremium;
	}
	
	public boolean isWaitPay(){
		return this.orderStatus == OrderStatus.wait_pay;
	}
	
	public boolean isAlreadyPay(){
		return this.orderStatus == OrderStatus.already_pay;
	}
	
	public boolean isRefundPay(){
		return this.orderStatus == OrderStatus.refund_pay;
	}
	
	public String getMessageId() {
		return messageId;
	}

	public static interface OrderStatus{
		public static final int wait_pay = 10;
		public static final int already_pay = 20;
		public static final int refund_pay = 30;
	} 

}
